<template>
	<view>
		<view class="mdcpntent">
			<image class="mdbg" src="../../static/pages_my/mdbg.png" mode="widthFix"></image>
			<u-navbar title="我的魔豆" leftIconColor='#fff' :placeholder='true' :titleStyle='titleStyle ' :bgColor='bgColor'
				 :autoBack="true">
			</u-navbar>
			<view class="Ntitle" style="color: #fff;">当前魔豆</view>
			<view class="price flex">
				<view class="u-font-bold u-font-60">{{credit}}</view>
				<view class="recharge" @click="$goTo('/pages_my/recharge/recharge?credit=' + credit)">充值</view>
			</view>
			<view class="detiallist">
				<view class="u-font-bold u-font-40">交易明细</view>
				<view class="detailbox flex" v-for="i in list">
					<view class="detailbox_left flex">
						<view class="">{{i.memo}}</view>
						<view class="time">{{i.createtime |date}}</view>
					</view>
					<!-- <view class="detailbox_right u-font-bold">
						+20
					</view> -->
					<view class="detailbox_rights u-font-bold">
						{{i.credit}}
					</view>
				</view>
			</view>
			<u-empty v-if="list==''"></u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgColor: 'rgba(0, 0, 0, 0)',
				titleStyle: 'color:#fff',
				page:1,
				credit:'',
				list:''
			};
		},
		onShow() {
			
			this.getInfo()
		},
		onLoad() {
			this.init()
		},
		onReachBottom() {
			this.page++
			this.init()
		},
		methods:{
			getInfo(){
				this.$api.post('/creditlist',{page:this.page}).then(res=>{
					this.credit = res.data.credit
				})
			},
			init(){
				this.$api.post('/creditlist',{page:this.page}).then(res=>{
					this.list = [...this.list,...res.data.list]
				})
			},
		}
	}
</script>

<style lang="scss">
	.mdcpntent {
		position: relative;
		overflow: hidden;
		.mdbg {
			position: absolute;
			width: 100%;
			// height: 436rpx;
		}

		.Ntitle {
			margin: 80rpx 30rpx 0rpx;
			position: relative;
		}

		.price {
			justify-content: space-between;
			padding: 10rpx 30rpx;
			position: relative;
			color: #fff;
			display: flex;
			align-items: center;
			box-sizing: border-box;
		}

		.recharge {
			border-radius: 30rpx;
			padding: 10rpx 30rpx;
			border: 2rpx solid #fff;
		}

		.detiallist {
			// border-radius: 30rpx;
			background-color: #F8F8FA;
			position: relative;
			padding: 40rpx;
			margin-top: 50rpx;
			.detailbox{
				margin-top: 20rpx;
				background-color: #fff;
				border-radius: 20rpx;
				align-items: center;
				padding:20rpx;
				justify-content: space-between;
				.detailbox_left{
					flex-direction: column;
					.time{
						color: #999;
						margin-top: 20rpx;
						font-size: 26rpx;
					}
				}
				.detailbox_right{
					color: #203460;
				}
				.detailbox_right{
					color: #00CE9B;
				}
			}
		}
	}
</style>